package com.tcjk.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.tcjk.service.DemoService;

@Controller
@RequestMapping("/demo")
public class DemoController {
	@Autowired
	DemoService demoService;
	
	@RequestMapping("/test")
	@ResponseBody
	public String test(){
		return demoService.test();
	} 
	
	@RequestMapping("/index")
	public String index(){
		return "index";
	}

	@RequestMapping(value="/save",produces = {"application/json;charset=UTF-8"})
	@ResponseBody
	public String save(String name){
		return "save保存成功：" + demoService.save(name).toString();
	}

	@RequestMapping(value="/del",produces = {"application/json;charset=UTF-8"})
	@ResponseBody
	public String delete(int id){
		return "del删除结果:" + demoService.delete(id);
	}

	@RequestMapping(value="/find",produces = {"application/json;charset=UTF-8"})
	@ResponseBody
	public String findAll(){
		return "find查询结果:" + demoService.findAll();
	}
}